authApp.controller("applyMController",function($scope,$http){
	$scope.isAddM=true;
	var requestJson={'pageNumber':'1','pageSize':'10','fid':'0','type':'0'};
	$scope.addM=function(){
		$scope.isAddM=false;
	}
	$scope.cancelAddM=function(){
		$scope.isAddM=true;
		$scope.addFZ="";
	}
	$scope.addFirstZ=function(){
		if($scope.addFZ){
			var rJson={'content':$scope.addFZ,'fid':'0','type':'0','number':'0'};
			$http({
				method:'post',
				url:apis.insertItem,
				data:rJson,
			}).success(function(response){
				var radom=Math.random();
				if(response.code=="000000"){
					$scope.isAddM=true;
					$scope.getAML();
				}else{
					alert(response.errorMsg);
				}
			}).error(function(){
				alert("服务器打瞌睡了，请稍等！");
				$scope.isAddM=true;
			})
		}else{
			alert("请输入一级指标");
		}
	}
	$scope.getAML=function(){
		$http({
			method:'post',
			url:apis.queryItem,
			data:requestJson,
		}).success(function(response){
			if(response.code=="000000"){
				$scope.list=response.data.data;
			}else{
				alert(response.errorMsg);
			}
		}).error(function(){
			alert("服务器打瞌睡了，请稍等！");
		})
	}
	$scope.delCollect=function(pid){
		if(window.confirm("是否确定删除？")){
			var rJson={'pid':pid};
			$http({
				method:'post',
				url:apis.deleteItem,
				data:rJson,
			}).success(function(response){
				if(response.code=="000000"){
					$scope.getAML();
				}else{
					alert(response.errorMsg);
				}
			})
		}
	}
	$scope.turnTo=function(pid){
		location.href="meterial_apply_sl.html?pid="+pid;
	}
	$scope.getAML();
})


authApp.controller("applySLMController",function($scope,$http,$location,$getQueryString,$splice){
	$scope.isAddM=true;
	var requestJson={'pageNumber':'1','pageSize':'10','fid':$getQueryString("pid"),'type':'1'};
	$scope.addM=function(){
		$scope.isAddM=false;
	}
	$scope.cancelAddM=function(){
		$scope.isAddM=true;
		$scope.addFZ="";
	}
	$scope.addFirstZ=function(){
		if($scope.addFZ){
			if($scope.addBZ){
				var rJson={'content':$scope.addFZ,'fid':$getQueryString("pid"),'type':'1','number':'0'};
				$http({
					method:'post',
					url:apis.insertItem,
					data:rJson,
				}).success(function(response){
					var radom=Math.random();
					if(response.code=="000000"){
						var rJson={'content':$scope.addBZ,'fid':response.data.pid,'type':'3','number':'0'};
						$http({
							method:'post',
							url:apis.insertItem,
							data:rJson,
						}).success(function(response){
							if(response.code=="000000"){
								$scope.isAddM=true;
								$scope.getAML();
							}
						}).error(function(){
							alert("服务器打瞌睡了，请稍等！");
							$scope.isAddM=true;
						})
					}else{
						alert(response.errorMsg);
					}
				}).error(function(){
					alert("服务器打瞌睡了，请稍等！");
					$scope.isAddM=true;
				})
			}else{
				alert("请输入二级指标标准");
			}
		}else{
			alert("请输入二级指标标题");
		}
	}
	$scope.getAML=function(){
		$http({
			method:'post',
			url:apis.queryItem,
			data:requestJson,
		}).success(function(response){
			if(response.code=="000000"){
				$scope.list=response.data.data;
			}else{
				alert(response.errorMsg);
			}
		}).error(function(){
			alert("服务器打瞌睡了，请稍等！");
		})
	}
	$scope.delCollect=function(pid){
		if(window.confirm("是否确定删除？")){
			var rJson={'pid':pid};
			$http({
				method:'post',
				url:apis.deleteItem,
				data:rJson,
			}).success(function(response){
				if(response.code=="000000"){
					$scope.getAML();
				}else{
					alert(response.errorMsg);
				}
			})
		}
	}
	$scope.turnTo=function(pid){
		location.href="m-detail.html?pid="+pid;
	}
	$scope.getAML();
})


